﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MailIn.aspx.cs" Inherits="InformationSystem.WebSite.Module.MailMgr.MailIn" %>

<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function callback() {
            parent.ResizeFrameHeight(GridPanel1.getHeight());
            //parent.ResizeFrameHeight(ViewPort1.getHeight(500));
        }
    </script>
    <script type="text/javascript">

        var removeMailIn = function () {
            var grid = GridPanel1;
            grid.deleteSelected();
            mailStore.save();
        }
        function callback() {
            parent.ResizeFrameHeight(GridPanel1.getHeight());
        }
        function godetail(uri) {
            var win = parent.Ext.getCmp('PFR');
            if (win)
                win.iframe.dom.contentWindow.location.href = uri;
        }
        function linkRenderer(value, meta, record) {
            return String.format("<div style='cursor: pointer;font-size:13;' onclick='godetail(\"MailContentView.aspx?mailid={0}\")'><a>{1}</a></div>", record.data.mailid, value);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager runat="server">
        <Listeners>
            <DocumentReady Fn="callback()" />
        </Listeners>
    </ext:ResourceManager>
    <ext:GridPanel ID="GridPanel1" runat="server" Frame="true" StripeRows="true" Title="收件箱"
        AutoExpandColumn="mailsubject" AnimCollapse="false" Icon="Email" TrackMouseOver="false"
        Width="650" Height="450">
        <Store>
            <ext:Store ID="mailStore" runat="server" GroupOnSort="false" GroupField="grouptip"
                RemoteSort="true" OnBeforeRecordDeleted="BeforeRecordDeleted" OnAfterStoreChanged="AfterStoreChanged">
                <SortInfo Direction="DESC" Field="sendtime" />
                <Reader>
                    <ext:JsonReader IDProperty="MailID">
                        <Fields>
                            <ext:RecordField Name="mailid" Mapping="MailID" Type="Int" />
                            <ext:RecordField Name="mailsubject" Mapping="MailSubject" Type="String" />
                            <ext:RecordField Name="senduserid" Mapping="SendUserID" Type="String" />
                            <ext:RecordField Name="sendusername" Mapping="SendUserName" Type="String" />
                            <ext:RecordField Name="hasattachment" Mapping="HasAttachment" Type="Boolean" />
                            <ext:RecordField Name="createtime" Mapping="CreateTime" Type="Date" />
                            <ext:RecordField Name="sendtime" Mapping="SendTime" Type="Date" />
                            <ext:RecordField Name="recvusername" Mapping="RecvUserNameList" Type="String" />
                            <ext:RecordField Name="grouptip" Mapping="GroupTip" Type="String" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
        </Store>
        <ColumnModel runat="server">
            <Columns>
                <ext:Column DataIndex="grouptip" />
                <ext:Column ColumnID="sendusername" Header="发件人" DataIndex="sendusername" Width="50">
                    <Renderer Fn="linkRenderer" />
                </ext:Column>
                <ext:Column ColumnID="mailsubject" Header="主题" DataIndex="mailsubject" Width="200">
                    <Renderer Fn="linkRenderer" />
                </ext:Column>
                <ext:DateColumn ColumnID="sendtime" Header="时间" DataIndex="sendtime" Width="60" Format="yyyy/MM/dd HH:mm:ss" />
            </Columns>
        </ColumnModel>
        <View>
            <ext:GroupingView runat="server" ForceFit="true" MarkDirty="false" ShowGroupName="false"
                EnableNoGroups="true" HideGroupedColumn="true" />
        </View>
        <TopBar>
            <ext:Toolbar runat="server">
                <Items>
                    <ext:Button ID="Button1" runat="server" Text="删除" Icon="EmailDelete" ToolTip="删除选中邮件">
                        <Listeners>
                            <Click Fn="removeMailIn" />
                        </Listeners>
                    </ext:Button>
                    <ext:Button ID="Button2" runat="server" Text="刷新" Icon="ArrowRefresh" ToolTip="刷新邮件列表">
                        <DirectEvents>
                            <Click OnEvent="btnRefresh_Click">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <SelectionModel>
            <ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server">
            </ext:CheckboxSelectionModel>
        </SelectionModel>
    </ext:GridPanel>
    </form>
</body>
</html>
